package com.lzx.dormsys.controller;

import java.util.List;

import com.lzx.dormsys.core.AjaxResult;
import com.lzx.dormsys.core.controller.BaseController;
import com.lzx.dormsys.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lzx.dormsys.bean.PersonBean;
import com.lzx.dormsys.service.IPersonBeanService;

/**
 * personController
 *
 * @author lzx
 * @date 2021-09-09
 */
@RestController
@RequestMapping("/personAction")
public class PersonBeanController extends BaseController
{
    @Autowired
    private IPersonBeanService personBeanService;

    /**
     * 查询person列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PersonBean personBean)
    {
        startPage();
        List<PersonBean> list = personBeanService.selectPersonBeanList(personBean);
        return getDataTable(list);
    }

    /**
     * 获取person详细信息
     */
    @GetMapping(value = "/{personId}")
    public AjaxResult getInfo(@PathVariable("personId") Long personId)
    {
        return AjaxResult.success(personBeanService.selectPersonBeanById(personId));
    }

    /**
     * 新增person
     */
    @PostMapping
    public AjaxResult add(@RequestBody PersonBean personBean)
    {
        return toAjax(personBeanService.insertPersonBean(personBean));
    }

    /**
     * 修改person
     */
    @PutMapping
    public AjaxResult edit(@RequestBody PersonBean personBean)
    {
        return toAjax(personBeanService.updatePersonBean(personBean));
    }

    /**
     * 删除person
     */
	@DeleteMapping("/{personIds}")
    public AjaxResult remove(@PathVariable Long[] personIds)
    {
        return toAjax(personBeanService.deletePersonBeanByIds(personIds));
    }
}
